import type { Serializable } from "@/stores/plugins/persist"

namespace ThemeTypes {
  export type Type = "auto" | "light" | "dark" | "custom"
  export type Value = "light" | "dark"

  export interface ColorSet {
    value: string
    hover: string
    pressed: string
    suppl: string
  }

  export const Colors = new Map<string, ColorSet>([
    [
      "#ff6b6b",
      <ColorSet>{
        value: "#ff6b6b",
        hover: "#ff8787",
        pressed: "#f03e3e",
        suppl: "#ff8787"
      }
    ],
    [
      "#f06595",
      <ColorSet>{
        value: "#f06595",
        hover: "#f783ac",
        pressed: "#d6336c",
        suppl: "#f783ac"
      }
    ],
    [
      "#cc5de8",
      <ColorSet>{
        value: "#cc5de8",
        hover: "#da77f2",
        pressed: "#ae3ec9",
        suppl: "#da77f2"
      }
    ],
    [
      "#845ef7",
      <ColorSet>{
        value: "#845ef7",
        hover: "#9775fa",
        pressed: "#7048e8",
        suppl: "#9775fa"
      }
    ],
    [
      "#5c7cfa",
      <ColorSet>{
        value: "#5c7cfa",
        hover: "#748ffc",
        pressed: "#4263eb",
        suppl: "#748ffc"
      }
    ],
    [
      "#339af0",
      <ColorSet>{
        value: "#339af0",
        hover: "#4dabf7",
        pressed: "#1c7ed6",
        suppl: "#4dabf7"
      }
    ],
    [
      "#22b8cf",
      <ColorSet>{
        value: "#22b8cf",
        hover: "#3bc9db",
        pressed: "#1098ad",
        suppl: "#3bc9db"
      }
    ],
    [
      "#20c997",
      <ColorSet>{
        value: "#20c997",
        hover: "#38d9a9",
        pressed: "#0ca678",
        suppl: "#38d9a9"
      }
    ],
    [
      "#51cf66",
      <ColorSet>{
        value: "#51cf66",
        hover: "#69db7c",
        pressed: "#37b24d",
        suppl: "#69db7c"
      }
    ],
    [
      "#94d82d",
      <ColorSet>{
        value: "#94d82d",
        hover: "#a9e34b",
        pressed: "#74b816",
        suppl: "#a9e34b"
      }
    ],
    [
      "#fcc419",
      <ColorSet>{
        value: "#fcc419",
        hover: "#ffd43b",
        pressed: "#f59f00",
        suppl: "#ffd43b"
      }
    ],
    [
      "#ff922b",
      <ColorSet>{
        value: "#ff922b",
        hover: "#ffa94d",
        pressed: "#f76707",
        suppl: "#ffa94d"
      }
    ]
  ])

  export class Variables extends Map<string, string> implements Serializable {
    deserialize(value: string) {
      const json = JSON.parse(value)
      for (const key of Object.keys(json)) {
        this.set(key, json[key])
      }
    }

    serialize(): string {
      const result: any = {}
      for (const [k, v] of this.entries()) {
        result[k] = v
      }
      return JSON.stringify(result)
    }
  }
}

export default ThemeTypes
